/////precompiled////////
#include "precompiled.h"
////////////////////////


#include "frm_TStyle.h"
using namespace frm;

// TTableOfStyles /////////////////////////////////////////////////////////////

//
TStyle *TTableOfStyles::SearchByType(svl::TType &Type)
{
//const char *S=typeid(Type).name();

  svl::TArray Result; a.SearchByType(Type,Result); if (Result.Count()) {
    return static_cast<TStyle*>(Result.Get(0));
  }
  return NULL;
}

//
TStyle *TTableOfStyles::SearchByEqualType(svl::TType &Type)
{
//const char *S=typeid(Type).name();

  svl::TArray Result; a.SearchByEqualType(Type,Result); if (Result.Count()) {
    return static_cast<TStyle*>(Result.Get(0));
  }
  return NULL;
}

//
void TTableOfStyles::Add(TStyle *P,bool EnDelete) 
{ 
  if (SearchByEqualType(P->Type())) {
    Except("Add[SearchByEqualType(P->Type)]");
  }
  a.Add(P,EnDelete);
}

//
void TTableOfStyles::DeleteIfSearchByEqualType(svl::TType &Type) 
{
  TStyle *P = SearchByEqualType(Type); if (P) {
    Delete(P);
  }
}

//
void TTableOfStyles::ReplaceLinkFrom(TTableOfStyles &From)
{
  for (int N = 0; N < From.Count(); N++) {
    TStyle *P = &From.Get(N); 
    DeleteIfSearchByEqualType(P->Type());
    Add(P,false); 
  }
}
